<template>
  <div>
    <div class="index_head">
      <van-image
        v-if="id===null"
        @click="jumpLogin()"
          class="index_touxiang"
          round
          width="3rem"
          height="3rem"
          src=""
        />
        <van-image
        v-else
        @click="jumpTouxiangDetail()"
          class="index_touxiang"
          round
          width="3rem"
          height="3rem"
          :src="url"
        />
      <van-search
       @focus="jumpSouSuo()"
        class="index_search"
        shape="round"
        background="#6c90f3"
        v-model="value"
        placeholder="请输入搜索关键词"
      />
      <van-icon
        class="index_soft"
        name="send-gift-o"
        size="30"
        color="whitesmoke"
      />
      <van-icon
        v-if="id===null"
        @click="jumpLogin()"
          class="index_chat"
          name="chat-o"
          size="30"
          color="whitesmoke"
        />
        <van-icon
        v-else
        @click="jumpNotice()"
          class="index_chat"
          name="chat-o"
          size="30"
          color="whitesmoke"
        />
    </div>
    <br />
    <div class="digital_type">
      <div class="digital_type1" v-for="(item, index) in list" :key="index" @click="jumpDigitalClassification(item,index)">
        <van-image
          width="30"
          height="40"
          :src="item.digital_category_image_roed"
        />
        <p class="digital_type_p1">{{ item.digital_category_name }}</p>
      </div>
      <div class="digital_type2" @click="jumpClassification()">
        <van-icon name="more" size="30" />
        <p class="digital_type_p2">全部</p>
      </div>
    </div>
    <br />
    <!-- 5热门 -->
    <div class="guess_like">
      <div class="guess_text">
        <span class="guess_text_sp1">今日热门</span>
      </div>
      <br />
      <br />
      <div
        @click.stop="jumpDetail(item1, index1)"
        class="guess_like_show"
        v-for="(item1, index1) in brandList"
        :key="index1"
      >
        <van-image
          radius="10"
          class="guess_like_img"
          width="50"
          height="50"
          :src="item1.digital_image_road"
        />
        <span class="guess_like_sp1">{{ item1.digital_name }}</span>
        <span class="guess_like_sp2">{{ item1.digital_heat }}热度&nbsp;{{ item1.digital_discuss }}讨论</span
        >
        <!-- <span class="guess_like_sp3">{{ item1.digital_discuss }}讨论</span> -->
        <span class="score_sp1">{{item1.digital_score}}.0</span>
        <el-rate
        class="show_score"
        :max="5"
        :allow-half="true"
          :value="item1.digital_score/2"
          disabled
          disabled-void-color="#D5D4D3"
          text-color="#F3780C"
        >
        </el-rate>
        <!-- <van-button
                  @click.stop="downloadButton(item1, index1)"
                  class="guess_like_small"
                  size="small"
                  round
                  type="info"
                  >下载</van-button
                > -->
      </div>
    </div>
    <div class="foot"></div>
  </div>
</template>
<script>
import { Toast } from 'vant';
import http from '../api/index';
export default {
  data() {
    return {
      value: '',
      values: '',
      active: 1,
      id:0,
      careList: [],
      list: [],
      brandList: [],
      id: sessionStorage.getItem('roleId'),
      url: sessionStorage.getItem('src'),
    };
  },
  mounted() {
    http
      .getDigitalType({
        pages: 1,
        digital_category_id: 1,
      })
      .then((r) => {
        console.log(r);
        this.list = r.data;
      });
    // 获取品牌信息
    http
      .getDigitalBrand({
        pages: 1,
      })
      .then((r) => {
        console.log(r);
        this.brandList = r.data;
        console.log()
      });
  },
  methods: {
    // 搜索
    jumpSouSuo(){
      this.$router.push('/sousuo');

    },
    jumpLogin(){
      this.$router.push('/login');

    },
    // 通知
    jumpNotice(){
      this.$router.push('/notice');

    },
    // 跳到详情
    jumpDetail(item, index) {
      this.$router.push('/digitalDetails/' + item.digital_id);
    },
    // 跳到用户信息
    jumpTouxiangDetail(){
      this.$router.push('/detail');
    },
    // 跳到数码分类
    jumpDigitalClassification(item,index){
      this.$router.push('/digitalClassification/'+item.digital_category_id);
    },
    jumpClassification(){
      this.$router.push('/digitalClassification/'+this.id);

    }
  },
};
</script>
<style scoped>
.index_head {
  width: 100%;
  height: 5.5rem;
  background-color: #6c90f3;
  position: sticky;
  top: 0;
  z-index: 5;
}
.index_touxiang {
  position: absolute;
  top: 1rem;
  left: 1rem;
}
.index_search {
  position: absolute;
  width: 26rem;
  left: 4.1rem;
}
.index_soft {
  position: absolute;
  top: 1.2rem;
  right: 4.4rem;
}
.index_chat {
  position: absolute;
  top: 1.2rem;
  right: 0.6rem;
}
.index_care {
  width: 100%;
  height: 20rem;
  background-color: white;
  border-radius: 1rem;
  margin-top: 2rem;
  position: relative;
}
.index_care_touxiang {
  position: absolute;
  top: 1rem;
  left: 1rem;
}
.digital_type {
  width: 96%;
  margin: 0 auto;
  background-color: white;
  border-radius: 1.5rem;
  height: 15rem;
  /* display: flex;
  justify-content:space-around;
  align-items: flex-start;
  flex-wrap: wrap; */
}
.digital_type1 {
  width: 5.5rem;
  height: 4rem;
  margin-left: 1.7rem;
  margin-top: 1rem;
  display: inline-block;
}
.digital_type2 {
 position: absolute;
 top: 15.8rem;
 left: 30.9rem;
}
.digital_type_p1 {
  margin-left: -2.7rem;
  text-align: center;
}
.digital_type_p2 {
  margin-left: -0.2rem;
  text-align: center;
}
.guess_like {
  width: 96%;
  margin: 0 auto;
  border-radius: 1.5rem;
  background-color: white;
}
.guess_text {
  position: relative;
}
.guess_text_sp1 {
  position: absolute;
  left: 1.5rem;
  top: 1.5rem;
  font-size: 1.6rem;
}
.guess_arrow {
  position: absolute;
  right: 1rem;
  top: 1.3rem;
  font-size: 2rem;
}
.guess_like_show {
  width: 96%;
  height: 6rem;
  position: relative;
  margin-top: 2rem;
}
.guess_like_img {
  position: absolute;
  top: 0px;
  left: 2rem;
  border-radius: 1rem;
}
.guess_like_sp1 {
  position: absolute;
  top: 0.1rem;
  left: 8.5rem;
  font-size: 1.8rem;
  color: #252525;
}
.guess_like_sp2 {
  position: absolute;
  top: 3rem;
  left: 8.5rem;
  font-size: 1.4rem;
  color: #7a7a7a;
}
.guess_like_sp3 {
  position: absolute;
  top: 0.5rem;
  left: 12.5rem;
  font-size: 1.4rem;
  color: #7a7a7a;
}
.guess_like_small {
  position: absolute;
  top: 0.8rem;
  right: 0px;
  width: 7rem;
}
.good_soft_show {
  display: inline-block;
  margin-top: 2rem;
  margin-left: 4.5rem;
}
.good_soft_img {
  display: inline-block;
}
.good_soft_p1 {
  font-size: 1.6rem;
  margin-left: -0.3rem;
  margin-top: 0.5rem;
}
.foot {
  width: 100%;
  height: 10rem;
}
.show_score{
  position: absolute;
  right: -2rem;
  top: 3rem;
}
.score_sp1{
  font-size: 2.4rem;
  color: #242222;
  position: absolute;
  top: -1rem;
  left: 28.5rem;
  font-weight: bold;
}
</style>